#ifndef BJSQL_H
#define BJSQL_H

#include "tracksql.h"

class BJOptions;
class BJSavedGame;
class BJRules;

//
// All money values are in cents (100 == $1, 25 == $.25, 1 == $.01)
//
// IMPORTANT:  Access to this class is NOT thread-safe.  That's handled at
//			   the next level up (with calls to lock()/unlock()).
//

class BJSQL : public TrackSQL
{
	public:
		BJSQL(const String& DBDSN, const String& DBLogin, const String& DBPassword);
		int32 gameDone
		(
			char *gid
		);


		int32 getMachineOptions( uint8 machid, uint8* ruleSetId, uint8* nDecks, uint8 *nBets );
	
		int32 getRuleSet
		(
			uint8		ruleSetId,
			BJRules*	pRules
		);

        int32 createGame(int32	casinoId,PID pid,bool8 forMoney,uint8 machid,
        	SESSIONID sessionId,int32 compFactor,char *gid,int32 bet, int32 *pBonusBalanceBet,
            uint8 iBJBet, uint8 nBets, char *tieID, int32 nSideBet);

		int32 setInsuranceState( char *gid,uint8	state,int32	payout,int32 *balance );

        // kharmon.  02-13-07.  #16101.  Added for new Perfect Pairs sidebet option.
        int32 setSideBetResult( char* acGID,uint8 ucState,int32 nPayout,int32 *pnBalance );		
		int32 getSideBetOptions(uint8 machid, uint8* paytable);

		int32 createDealerHand
		(
			char*	gid,
			int32		numcards,
			uint8*		cards
		);

		int32 saveDealerHand
		(
			char*	gid,
			uint8		numcards,
			uint8*		cards
		);

		int32 savePlayerHand( char *gid, uint8 handNum, uint8 nBets,
					  uint8	numcards, uint8* cards, uint8 bet, uint8 hit,
					  uint8	stand, uint8 doubled, uint8	split, uint8 surrender,
					  uint8	raise, uint8 zap,				/// [2013-07-10] Charles. Added for supporting 'Zappit Rackcard'.								
					  bool8 adjustBalance,	int32* balance,
					  int32* bonusBalanceBet);

		int32 addDealerCards(char*, int32 numcards, uint8* cards);
		int32 setPlayerPayout(char*, int32 handNum, int32 payout);

		int32 hasSavedGame( const PID&	pid,bool8 forMoney,uint8 machid,BJSavedGame* sg, bool8* exists);

		int32 removeSavedGame(char*	gid);
		int32 saveGame(const PID&, bool8 forMoney, BJSavedGame*);

		int32 getForcedHands
		(
			char*	pForcedHandDealer,
			char*	pForcedHandPlayer,
			int32	nBytesPerHand
		);

		int32 resetSavedGame( char *gid=(char*)0 );

		enum BJSQLError
		{
			BadSavedGame = TrackSQL::FIRST_GAME_ERROR
		};
};

#endif
